import { defineStore } from 'pinia'
import { ref } from 'vue';
export const useCounterStore = defineStore('counter', () => {
//   const count = ref(0)
//   const doubleCount = computed(() => count.value * 2)
//   function increment() {
//     count.value++
//   }

//   return { count, doubleCount, increment }

//定义订单列表
const myOrderList=ref([]);

const orderList=(payload)=>{
    const index=myOrderList.value.findIndex(item=>item.id==payload.id);
    if(index>-1){
        myOrderList.value[index].count++;
    }
    else{
        myOrderList.value.push({
            ...payload,
            count:1,
            checked:false,
        })
    }
}


return {myOrderList,orderList}
},{
    persist:true,
})